"use strict";
/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up(queryInterface, Sequelize) {
    await queryInterface.createTable("Menus", {
      id: {
        allowNull: false,
        autoIncrement: true,
        primaryKey: true,
        type: Sequelize.INTEGER.UNSIGNED,
        comment: "菜单ID",
      },
      pid: {
        defaultValue: 0,
        type: Sequelize.INTEGER.UNSIGNED,
        comment: "菜单PID，父级ID",
      },
      name: {
        allowNull: false,
        type: Sequelize.STRING(45),
        comment: "菜单名称",
      },
      menuType: {
        allowNull: false,
        defaultValue: 0,
        type: Sequelize.TINYINT,
        comment: "菜单类型，0：菜单，1：按钮",
      },
      title: {
        type: Sequelize.STRING(45),
        comment: "菜单标题",
      },
      path: {
        type: Sequelize.STRING,
        comment: "菜单路由",
      },
      component: {
        type: Sequelize.STRING,
        comment: "菜单组件",
      },
      redirect: {
        type: Sequelize.STRING,
        comment: "菜单重定向地址",
      },
      icon: {
        type: Sequelize.STRING(100),
        comment: "菜单图标",
      },
      sort: {
        defaultValue: 0,
        type: Sequelize.INTEGER,
        comment: "菜单排序",
      },
      position: {
        defaultValue: 0,
        type: Sequelize.INTEGER,
        comment: "菜单初始位置",
      },
      hidden: {
        defaultValue: false,
        type: Sequelize.BOOLEAN,
        comment: "是否在菜单栏中显示",
      },
      affix: {
        defaultValue: false,
        type: Sequelize.BOOLEAN,
        comment: "是否一直固定在tagview中",
      },
      noTagView: {
        defaultValue: false,
        type: Sequelize.BOOLEAN,
        comment: "是否在tagview中不显示",
      },
      alwaysShow: {
        defaultValue: false,
        type: Sequelize.BOOLEAN,
        comment: "当子级只有一级的时候菜单是否显示完整路由",
      },
      noCache: {
        defaultValue: false,
        type: Sequelize.BOOLEAN,
        comment: "是否取消菜单缓存",
      },
      createdAt: {
        allowNull: false,
        type: Sequelize.DATE,
        comment: "创建时间",
      },
      updatedAt: {
        allowNull: false,
        type: Sequelize.DATE,
        comment: "更新时间",
      },
    });
    await queryInterface.addIndex("Menus", {
      fields: ["name"],
      unique: true,
    });
  },
  async down(queryInterface, Sequelize) {
    await queryInterface.dropTable("Menus");
  },
};
